<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>AI 面试系统 - 我的面试</title>
    <link
      href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css"
      rel="stylesheet"
    />
    <link
      rel="stylesheet"
      href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css"
    />
  </head>
  <body>
    <nav class="navbar navbar-expand-lg navbar-dark bg-primary">
      <div class="container">
        <a class="navbar-brand" href="#">AI 面试系统</a>
        <button
          class="navbar-toggler"
          type="button"
          data-bs-toggle="collapse"
          data-bs-target="#navbarNav"
        >
          <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarNav">
          <ul class="navbar-nav ms-auto">
            <li class="nav-item">
              <span class="nav-link"
                >欢迎, [[${#authentication?.principal?.username ?:
                '游客'}]]</span
              >
            </li>
            <li class="nav-item">
              <a class="nav-link active" href="#"
                ><i class="bi bi-list-ul"></i> 我的面试</a
              >
            </li>
            <li class="nav-item">
              <a class="nav-link" th:href="@{/interview}"
                ><i class="bi bi-plus-circle"></i> 开始新的面试</a
              >
            </li>
            <li class="nav-item">
              <a class="nav-link" th:href="@{/logout}">退出登录</a>
            </li>
          </ul>
        </div>
      </div>
    </nav>

    <div class="container mt-5">
      <div class="row">
        <div class="col-md-10 offset-md-1">
          <h2 class="mb-4">我的面试</h2>

          <div th:if="${interviews.isEmpty()}" class="alert alert-info">
            <h5><i class="bi bi-info-circle"></i> 欢迎使用AI面试系统</h5>
            <p>
              您还没有进行过任何面试。AI面试系统将根据您的简历和目标职位，生成个性化的面试问题，帮助您更好地准备面试。
            </p>
            <a th:href="@{/interview}" class="btn btn-primary">
              <i class="bi bi-play-circle"></i> 开始您的第一次面试
            </a>
          </div>

          <div th:unless="${interviews.isEmpty()}" class="card shadow">
            <div class="table-responsive">
              <table class="table table-hover mb-0">
                <thead class="table-light">
                  <tr>
                    <th><i class="bi bi-calendar"></i> 面试时间</th>
                    <th><i class="bi bi-briefcase"></i> 目标职位</th>
                    <th><i class="bi bi-star"></i> 评分</th>
                    <th><i class="bi bi-gear"></i> 操作</th>
                  </tr>
                </thead>
                <tbody>
                  <tr th:each="interview : ${interviews}">
                    <td>
                      <span
                        th:if="${interview.endTime != null}"
                        th:text="${interview.endTime}"
                      ></span>
                      <span
                        th:if="${interview.endTime == null}"
                        class="text-muted"
                        >进行中</span
                      >
                    </td>
                    <td>[[${interview.jobPosition}]]</td>
                    <td>
                      <span
                        th:if="${interview.finalScore != null}"
                        class="badge"
                        th:class="${interview.finalScore >= 7} ? 'bg-success' : (${interview.finalScore >= 4} ? 'bg-warning' : 'bg-danger')"
                      >
                        [[${#numbers.formatDecimal(interview.finalScore, 1,
                        'COMMA', 1, 'POINT')}]]/10
                      </span>
                      <span
                        th:if="${interview.finalScore == null}"
                        class="badge bg-secondary"
                        >未完成</span
                      >
                    </td>
                    <td>
                      <div class="btn-group" role="group">
                        <a
                          th:if="${interview.status.name() == 'COMPLETED'}"
                          th:href="@{/result/{id}(id=${interview.id})}"
                          class="btn btn-sm btn-primary"
                          title="查看面试结果"
                        >
                          <i class="bi bi-eye"></i> 查看结果
                        </a>
                        <a
                          th:if="${interview.status.name() == 'IN_PROGRESS'}"
                          th:href="@{/chat-interview/{id}(id=${interview.id})}"
                          class="btn btn-sm btn-warning"
                          title="继续面试"
                        >
                          <i class="bi bi-play-circle"></i> 继续面试
                        </a>
                        <a
                          th:href="@{/debug-interview/{id}(id=${interview.id})}"
                          class="btn btn-sm btn-outline-info"
                          title="调试信息"
                        >
                          <i class="bi bi-bug"></i>
                        </a>
                      </div>
                    </td>
                  </tr>
                </tbody>
              </table>
            </div>
          </div>
        </div>
      </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
  </body>
</html>
